package kaizen;

// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 07/02/2013 05:29:34 p.m.
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   pagolinea.java

import java.io.*;
import java.util.Properties;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import kaizen.jdbc.DbAppUnivC;
import kaizen.jdbc.dbRecord;
import kaizen.nomweb.*;

public class pagolinea extends HttpServlet
{

    public pagolinea()
    {
    }

    public static String Genera_JavaScript()
    {
        String s = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
        s = s + "<!-- Begin\n";
        s = s + "\n";
        s = s + "function formatCurrency(num)\n";
        s = s + "{\n";
        s = s + "   num = num.toString().replace(/\\$|\\,/g,'');\n";
        s = s + "   if(isNaN(num))\n";
        s = s + "      num = \"0\";\n";
        s = s + "   sign = (num == (num = Math.abs(num)));\n";
        s = s + "   num = Math.floor(num*100+0.50000000001);\n";
        s = s + "   cents = num%100;\n";
        s = s + "   num = Math.floor(num/100).toString();\n";
        s = s + "   if(cents<10)\n";
        s = s + "      cents = \"0\" + cents;\n";
        s = s + "   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)\n";
        s = s + "      num = num.substring(0,num.length-(4*i+3))+','+\n";
        s = s + "   num.substring(num.length-(4*i+3));\n";
        s = s + "   return (((sign)?'':'-') + num + '.' + cents);\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "function actualiza_saldo(j){\n";
        s = s + " a = document.frm.elements.tags('INPUT');\n";
        s = s + " var conta = 0;\n";
        s = s + " for(i=0; i<a.length; i++) { \n";
        s = s + "  if(a[i].type == 'checkbox'){ \n   conta++;\n";
        s = s + "  } \n";
        s = s + " } \n  ";
        s = s + " if (conta < 2){ \n";
        s = s + "  var test = document.frm.pago; \n";
        s = s + " } \n";
        s = s + " else{ \n";
        s = s + "   var test = document.frm.pago[j];\n ";
        s = s + "} \n";
        s = s + "   if (test.checked != false){ \n";
        s = s + "    if (conta <2) {\n";
        s = s + "      var totalPago = eval(\"document.frm.totPago\" + 0);\n  ";
        s = s + "    } \n";
        s = s + "    else{ \n";
        s = s + "       var totalPago = eval(\"document.frm.totPago\" + j);\n ";
        s = s + "    } \n";
        s = s + "  aa = document.frm.elements.tags('INPUT');   \n";
        s = s + "  var contaSaldo = 0;  \n";
        s = s + "  for(i=0; i<aa.length; i++) {  \n";
        s = s + "   var elcampo2 = aa[i].name; \n";
        s = s + "   if(aa[i].type=='text'){  \n";
        s = s + "     var strCompara2 = elcampo2.substring(0,5); \n";
        s = s + "     if ( strCompara2 == \"saldo\" ){ \n";
        s = s + "      contaSaldo++; \n";
        s = s + "     } \n";
        s = s + "   } \n";
        s = s + "  } \n";
        s = s + " if (contaSaldo < 2){ \n";
        s = s + "  var saldo = eval(\"document.frm.saldo0\"); \n";
        s = s + " } \n";
        s = s + " else{ \n";
        s = s + "  var saldo = eval(\"document.frm.saldo\" + j);\n";
        s = s + " } \n";
        s = s + "\t  totalPago.disabled = false;\n";
        s = s + "      totalPago.value = formatCurrency(saldo.value);\n";
        s = s + "      var subtotal = 0; \n";
        s = s + "     if (contaSaldo < 2) { \n";
        s = s + "        totalPago = eval(\"document.frm.totPago0\"); \n";
        s = s + "        var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "        subtotal = subtotal + valor;\n";
        s = s + "     } \n";
        s = s + "     else{ \n";
        s = s + "      for (i = 0; i < document.frm.pago.length; i++)\n";
        s = s + "      {\n";
        s = s + "         totalPago = eval(\"document.frm.totPago\" + i);\n";
        s = s + "\t\t var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "         subtotal = subtotal + valor;\n";
        s = s + "      } \n";
        s = s + "     } \n";
        s = s + "\n";
        s = s + "      document.frm.txtSub.value = formatCurrency(subtotal);\n";
        s = s + "\n";
        s = s + "      var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
        s = s + "      if (total == 0)\n";
        s = s + "         document.frm.txtTot.value = \"0.00\";\n";
        s = s + "      else\n";
        s = s + "         document.frm.txtTot.value = formatCurrency(total);\n";
        s = s + "   } \n";
        s = s + "   else { \n";
        s = s + "      var totalPago = eval(\"document.frm.totPago\" + j);\n";
        s = s + "\t     totalPago.disabled = true;\n";
        s = s + "      totalPago.value = \"0.00\";\n";
        s = s + "      var subtotal = 0;\n";
        s = s + "      for (i = 0; i < document.frm.pago.length; i++)\n";
        s = s + "      {\n";
        s = s + "         totalPago = eval(\"document.frm.totPago\" + i);\n";
        s = s + "         var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "         subtotal = subtotal + valor;\n";
        s = s + "      }\n";
        s = s + "      if (subtotal == 0)\n";
        s = s + "         document.frm.txtSub.value = \"0.00\";\n";
        s = s + "      else\n";
        s = s + "         document.frm.txtSub.value = formatCurrency(subtotal);\n";
        s = s + "\n";
        s = s + "      var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
        s = s + "      if (total == 0)\n";
        s = s + "         document.frm.txtTot.value = \"0.00\";\n";
        s = s + "      else\n";
        s = s + "         document.frm.txtTot.value = formatCurrency(total);\n";
        s = s + "   } \n ";
        s = s + "} \n";
        s = s + "\n";
        s = s + "function ineditable(j){ \n";
        s = s + "  var totalPago = eval(\"document.frm.totPago\" + j); \n";
        s = s + "  totalPago.disabled = true;\n";
        s = s + "} \n";
        s = s + "\n";
        s = s + "function disineditable(j){ \n";
        s = s + "  var totalPago = eval(\"document.frm.totPago\" + j);  \n";
        s = s + "  var saldo = eval(\"document.frm.saldo\" + j);  \n";
        s = s + "} \n";
        s = s + "\n";
        s = s + " function actualTotales(j){ \n";
        s = s + "     var conta = j; \n";
        s = s + "     if (conta <2) { \n";
        s = s + "       var totalPago = eval(\"document.frm.totPago\" + 0); \n";
        s = s + "     }  \n";
        s = s + "     else{  \n";
        s = s + "        var totalPago = eval(\"document.frm.totPago\" + j); \n";
        s = s + "     }  \n";
        s = s + "     aa = document.frm.elements.tags('INPUT');    \n";
        s = s + "     var contaSaldo = 0;   \n";
        s = s + "     for(i=0; i<aa.length; i++) {   \n";
        s = s + "         var elcampo2 = aa[i].name;  \n";
        s = s + "         if(aa[i].type=='text'){   \n";
        s = s + "             var strCompara2 = elcampo2.substring(0,5);  \n";
        s = s + "             if ( strCompara2 == \"saldo\" ){  \n";
        s = s + "                 contaSaldo++;  \n";
        s = s + "             }  \n";
        s = s + "         }  \n";
        s = s + "     }  \n";
        s = s + "     if (contaSaldo < 2){  \n";
        s = s + "         var saldo = eval(\"document.frm.saldo0\");  \n";
        s = s + "     }  \n";
        s = s + "     else{  \n";
        s = s + "         var saldo = eval(\"document.frm.saldo\" + j); \n";
        s = s + "     }  \n";
        s = s + "     totalPago.disabled = false; \n";
        s = s + "     //totalPago.value = formatCurrency(saldo.value); \n";
        s = s + "     var subtotal = 0;  \n";
        s = s + "     if (contaSaldo < 2) {  \n";
        s = s + "         totalPago = eval(\"document.frm.totPago0\");  \n";
        s = s + "         var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "         subtotal = subtotal + valor; \n";
        s = s + "     }  \n";
        s = s + "     else{  \n";
        s = s + "       for (i = 0; i < document.frm.pago.length; i++){ \n";
        s = s + "         totalPago = eval(\"document.frm.totPago\" + i); \n";
        s = s + " \tvar valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "         subtotal = subtotal + valor; \n";
        s = s + "       } \n";
        s = s + "     }  \n";
        s = s + "     document.frm.txtSub.value = formatCurrency(subtotal); \n";
        s = s + "     var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "     if (total == 0) \n";
        s = s + "          document.frm.txtTot.value = \"0.00\"; \n";
        s = s + "     else \n";
        s = s + "          document.frm.txtTot.value = formatCurrency(total); \n";
        s = s + "  }          \n";
        s = s + "function total(i) { \n";
        s = s + "  a = document.frm.elements.tags('INPUT');   \n";
        s = s + "  var contaTotPago = 0;  \n";
        s = s + "  for(i=0; i<a.length; i++) {  \n";
        s = s + "   var elcampo = a[i].name; \n";
        s = s + "   if(a[i].type=='text'){  \n";
        s = s + "     var strCompara = elcampo.substring(0,7); \n";
        s = s + "     if ( strCompara == \"totPago\" ){ \n";
        s = s + "      contaTotPago++; \n";
        s = s + "     } \n";
        s = s + "   } \n";
        s = s + "  } \n";
        s = s + " if (contaTotPago < 2){ \n";
        s = s + "  var totalPago = eval(\"document.frm.totPago0\"); \n";
        s = s + " } \n";
        s = s + " else{ \n";
        s = s + "   var totalPago = eval(\"document.frm.totPago\" + i);\n";
        s = s + " } \n";
        s = s + "  aa = document.frm.elements.tags('INPUT');   \n";
        s = s + "  var contaSaldo = 0;  \n";
        s = s + "  for(i=0; i<aa.length; i++) {  \n";
        s = s + "   var elcampo2 = aa[i].name; \n";
        s = s + "   if(aa[i].type=='text'){  \n";
        s = s + "     var strCompara2 = elcampo2.substring(0,5); \n";
        s = s + "     if ( strCompara2 == \"saldo\" ){ \n";
        s = s + "      contaSaldo++; \n";
        s = s + "     } \n";
        s = s + "   } \n";
        s = s + "  } \n";
        s = s + " if (contaSaldo < 2){ \n";
        s = s + "  var totalSaldo = eval(\"document.frm.saldo0\"); \n";
        s = s + " } \n";
        s = s + " else{ \n";
        s = s + "  var totalSaldo = eval(\"document.frm.saldo\" + i);\n";
        s = s + " } \n";
        s = s + "   if(parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,'')) > parseFloat(totalSaldo.value.toString().replace(/\\$|\\,/g,'')))\n";
        s = s + "   {\n";
        s = s + "      alert('El valor ingresado es mayor al saldo de la factura.');\n";
        s = s + "      totalPago.focus();\n";
        s = s + "   }\n";
        s = s + "   else\n";
        s = s + "   {\n";
        s = s + "      if(parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,'')) >= 0)\n";
        s = s + "      {\n";
        s = s + "         var subtotal = 0;\n";
        s = s + "         totalPago.value = formatCurrency(totalPago.value);\n";
        s = s + "\n";
        s = s + "         for (i = 0; i < document.frm.pago.length; i++) \n";
        s = s + "         {\n";
        s = s + "            totalPago = eval(\"document.frm.totPago\" + i);\n";
        s = s + "            var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
        s = s + "            subtotal = subtotal + valor;\n";
        s = s + "         }\n";
        s = s + "         if (subtotal == 0)\n";
        s = s + "            document.frm.txtSub.value = \"0.00\";\n";
        s = s + "         else\n";
        s = s + "            document.frm.txtSub.value = formatCurrency(subtotal);\n";
        s = s + "         var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
        s = s + "         if (total == 0)\n";
        s = s + "            document.frm.txtTot.value = \"0.00\";\n";
        s = s + "         else\n";
        s = s + "            document.frm.txtTot.value = formatCurrency(total);\n";
        s = s + "      }\n";
        s = s + "      else\n";
        s = s + "      {\n";
        s = s + "         alert('El importe ingresado es menor a 0.');\n";
        s = s + "         totalPago.value = formatCurrency(totalPago+i.value);\n";
        s = s + "         totalPago.focus();\n";
        s = s + "      }\n";
        s = s + "   }\n";
        s = s + " }\n";
        s = s + "\n";
        s = s + "function totalgen()\n";
        s = s + "{\n";
        s = s + "   if (parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,'')) >= 0)\n";
        s = s + "   {\n";
        s = s + "      var total_gen = parseFloat(document.frm.txtSub.value.toString().replace(/\\$|\\,/g,'')) + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
        s = s + "      document.frm.txtTot.value = formatCurrency(total_gen);\n";
        s = s + "      document.frm.txtAnti.value = formatCurrency(document.frm.txtAnti.value);\n";
        s = s + "   }\n";
        s = s + "   else\n";
        s = s + "   {\n";
        s = s + "      alert('El importe ingresado es menor a 0.');\n";
        s = s + "      document.frm.txtAnti.value = formatCurrency(document.frm.txtAnti.value);\n";
        s = s + "      document.frm.txtAnti.focus();\n";
        s = s + "   }\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "function valida()\n";
        s = s + "{\n";
        s = s + "   if(parseFloat(document.frm.txtTot.value.toString().replace(/\\$|\\,/g,'')) <= 0)\n";
        s = s + "   {\n";
        s = s + "      alert('El pago Total debe de ser mayor a 0');\n";
        s = s + "      return false;\n";
        s = s + "   }\n";
        s = s + "   else\n";
        s = s + "   {\n";
        s = s + "      if(GetCookie(\"namepago\") == null)\n";
        s = s + "      {\n";
        s = s + "         document.write(\"<table width=\\\"100%\\\" height=\\\"100%\\\" border=\\\"0\\\" background=\\\"/scm/media/fondop.jpg\\\">\");\n";
        s = s + "         document.write(\"  <tr>\");\n";
        s = s + "         document.write(\"    <td><div align=\\\"center\\\">Su transacci\363n a expirado.<br><a href=\\\"/scm/servlet/ConectAc?dic_estado=92&dic_menu=m01\\\">Para regresar a <img src=\\\"/scm/media/integra/interior_01.jpg\\\" alt=\\\"enlace@montezuma\\\" width=\\\"187\\\" height=\\\"41\\\" align=\\\"middle\\\"> dar click en la imagen.<a><br></div></td>\");\n";
        s = s + "         document.write(\"  </tr>\");\n";
        s = s + "         document.write(\"</table>\");\n";
        s = s + "\t        return false;\n";
        s = s + "      }\n";
        s = s + "\t     else\n";
        s = s + "\t     {\n";
        s = s + "         document.frm.edo_pago.value = \"1\";\n";
        s = s + "         document.frm.Submit.disabled = true;\n";
        s = s + "         createCookie(\"namepago\",\"\",-1);\n";
        s = s + "         return true;\n";
        s = s + "      }\n";
        s = s + "   }\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "function createCookie(name,value,days)\n";
        s = s + "{\n";
        s = s + "   if (days)\n";
        s = s + "   {\n";
        s = s + "      var date = new Date();\n";
        s = s + "      date.setTime(date.getTime()+(days*24*60*60*1000));\n";
        s = s + "      var expires = \"; expires=\"+date.toGMTString();\n";
        s = s + "   }\n";
        s = s + "   else var expires = \"\";\n";
        s = s + "   document.cookie = name+\"=\"+value+expires+\";\";\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "function getCookieVal (offset)\n";
        s = s + "{\n";
        s = s + "   var endstr = document.cookie.indexOf (\";\", offset);\n";
        s = s + "   if (endstr == -1)\n";
        s = s + "      endstr = document.cookie.length;\n";
        s = s + "   return unescape(document.cookie.substring(offset, endstr));\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "function GetCookie (name)\n";
        s = s + "{\n";
        s = s + "   var arg = name + \"=\";\n";
        s = s + "   var alen = arg.length;\n";
        s = s + "   var clen = document.cookie.length;\n";
        s = s + "   var i = 0;\n";
        s = s + "   while (i < clen)\n";
        s = s + "   {\n";
        s = s + "      var j = i + alen;\n";
        s = s + "      if (document.cookie.substring(i, j) == arg)\n";
        s = s + "         return getCookieVal (j);\n";
        s = s + "      i = document.cookie.indexOf(\" \", i) + 1;\n";
        s = s + "      if (i == 0) break;\n";
        s = s + "   }\n";
        s = s + "   return null;\n";
        s = s + "}\n";
        s = s + "\n";
        s = s + "// End -->\n";
        s = s + "</script>\n";
        return s;
    }

    public void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws ServletException, IOException
    {
        httpservletresponse.setContentType("text/html");
        PrintWriter printwriter = httpservletresponse.getWriter();
        HttpSession httpsession = httpservletrequest.getSession(false);
        if(httpsession != null && httpsession.getAttribute("usuario") != null)
            usuario = httpsession.getAttribute("usuario").toString();
        if(usuario == null)
            usuario = "";
        if(usuario.length() == 0)
            printwriter.println("Error, usuario no valido");
        String s = generaPagoLinea(httpservletrequest, httpservletresponse, usuario);
    }

    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws IOException, ServletException
    {
        doGet(httpservletrequest, httpservletresponse);
    }

    public static void generaAmbiente(HttpServletRequest httpservletrequest)
        throws IOException
    {
        String s = "mocte";
        String s1 = "/kaizen/" + s + "Web.properties";
        Properties properties = utilerias.loadProperties(s1);
        dirPlantillasGenerales = properties.getProperty("plantillas");
        datColorRen = "";
        datFont = properties.getProperty("datFont");
        datTamFont = properties.getProperty("datTamFont");
        datColorFont = properties.getProperty("datColorFont");
    }

    public static String generaPagoLinea(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, String s)
        throws IOException
    {
        HttpSession httpsession = httpservletrequest.getSession(false);
        String s1 = "";
        String s2 = "";
        String s3 = "";
        String s4 = "";
        String s5 = "";
        String s6 = "";
        String s7 = "";
        String s8 = "";
        String s9 = "";
        String s10 = "";
        String s11 = "";
        String s12 = "";
        generaAmbiente(httpservletrequest);
        String s13 = "";
        String s14 = utilerias.validaNulo(httpservletrequest.getParameter("edo_pago"));
        if(s14.equals("") || s14.equals("null"))
        {
            String s15 = genera_clientes(s, "");
            String s17 = templates.generaHidden("edo_pago", "0");
            String s19 = utilerias.replaceString1(templates.generaTexto("txtSub", "20", "20", "0.00"), ">", " disabled>");
            String s21 = utilerias.replaceString1(templates.generaTexto("txtAnti", "20", "20", "0.00"), ">", " disabled>");
            String s23 = utilerias.replaceString1(templates.generaTexto("txtTot", "12", "20", "0.00"), ">", " disabled>");
            s4 = utilerias.replaceString1(templates.generaTextArea("comentario", "1000", "60", "5", s4), ">", " disabled>");
            String s27 = templates.getHost();
            String s29 = dirPlantillasGenerales + plant_pago;
            String s31 = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
            s31 = s31 + "<!-- Begin\n";
            s31 = s31 + "function createCookie(name,value,days)\n";
            s31 = s31 + "{\n";
            s31 = s31 + "   if (days)\n";
            s31 = s31 + "   {\n";
            s31 = s31 + "      var date = new Date();\n";
            s31 = s31 + "      date.setTime(date.getTime()+(days*24*60*60*1000));\n";
            s31 = s31 + "      var expires = \"; expires=\"+date.toGMTString();\n";
            s31 = s31 + "   }\n";
            s31 = s31 + "   else var expires = \"\";\n";
            s31 = s31 + "   document.cookie = name+\"=\"+value+expires+\";\";\n";
            s31 = s31 + "}\n";
            s31 = s31 + "// End -->\n";
            s31 = s31 + "</SCRIPT>\n";
            s12 = templates.generaPlantilla(s29, s27);
            s12 = utilerias.replaceString1(s12, "--script--", s31);
            s12 = utilerias.replaceString1(s12, "--clientes--", utilerias.replaceString1(s15, "onChange=\"submit()\"", "onChange=\"createCookie('namepago','" + s + "', 1);submit()\""));
            s12 = utilerias.replaceString1(s12, "--tabla_grid--", "");
            s12 = utilerias.replaceString1(s12, "--txtSub--", s19);
            s12 = utilerias.replaceString1(s12, "--txtAnti--", s21);
            s12 = utilerias.replaceString1(s12, "--txtTot--", s23);
            s12 = utilerias.replaceString1(s12, "--txtCom--", s4);
            s12 = utilerias.replaceString1(s12, "--hidden--", s17);
            s12 = utilerias.replaceString1(s12, "--folio--", folio);
            s12 = utilerias.replaceString1(s12, "--comprobante--", "");
            s12 = utilerias.replaceString1(s12, "value=\"Procesar\">", "value=\"Procesar\" disabled>");
        } else
        {
            if(s14.equals("0"))
            {
                String s16 = httpservletrequest.getParameter("cliente");
                String s18 = " SELECT 1,'FACT', FACT_SERIE||'-'||TO_CHAR(FACT_NUMERO), FACT_SUBTOTAL_FACTURA + FACT_MONTO_IVA, FACT_SALDO_SUBTOTAL + FACT_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('FACT', FACT_SERIE, FACT_NUMERO, NULL) FROM SCC_FACTURAS WHERE  FACT_CLNT_NUMERO = " + s16 + " AND FACT_STATUS IN ('I','L','P','R') " + " AND FACT_SALDO_SUBTOTAL + FACT_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('FACT', FACT_SERIE, FACT_NUMERO, NULL) != 0 " + " UNION " + " SELECT 2,'NOCA', " + " NOCA_SERIE||'-'||TO_CHAR(NOCA_NUMERO), " + " NOCA_SUBTOTAL_NOTA + NOCA_MONTO_IVA, " + " NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('NOCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) " + " FROM SCC_NOTAS_CARGO " + " WHERE NOCA_CLNT_NUMERO = " + s16 + " AND NOCA_STATUS IN ('I','L','P','R') " + " AND NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('NOCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) != 0 " + " AND NOCA_TIPO_NOTA  = 'N'" + " UNION " + " SELECT 3,'AVCA', " + " NOCA_SERIE||'-'||TO_CHAR(NOCA_NUMERO), " + " NOCA_SUBTOTAL_NOTA + NOCA_MONTO_IVA, " + " NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('AVCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) " + " FROM SCC_NOTAS_CARGO " + " WHERE NOCA_CLNT_NUMERO = " + s16 + " AND NOCA_STATUS IN ('I','L','P','R') " + " AND NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('AVCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) != 0 " + " AND NOCA_TIPO_NOTA = 'A'" + " AND NOT EXISTS (SELECT 'X' " + " FROM SCC_NOTAS_CARGO_FACTURA " + " WHERE NOFA_NOCA_SERIE = NOCA_SERIE " + " AND NOFA_NOCA_NUMERO = NOCA_NUMERO " + " AND NOFA_NOCA_TIPO_NOTA = NOCA_TIPO_NOTA " + " AND NOFA_AFECTA_SUB = 'N' " + " UNION " + " SELECT 'X'  " + " FROM SCC_NOTAS_CARGO_CREDITO, SCC_NOTAS_CREDITO_FACTURA" + " WHERE NCCR_NOCA_SERIE = NOCA_SERIE " + " AND NCCR_NOCA_NUMERO = NOCA_NUMERO " + " AND NCCR_NOCA_TIPO_NOTA = NOCA_TIPO_NOTA  " + " AND NOCF_NOCR_SERIE = NCCR_NOCR_SERIE " + " AND NOCF_NOCR_NUMERO = NCCR_NOCR_NUMERO " + " AND NOCF_NOCR_TIPO_NOTA = NCCR_NOCR_TIPO_NOTA " + " AND NOCF_AFECTA_SUB = 'N') " + " UNION " + " SELECT 4,'PAGA',  " + " PAGA_SERIE||'-'||TO_CHAR(PAGA_NUMERO), " + " PAGA_SUBTOTAL_PAGARE + PAGA_MONTO_IVA, " + " PAGA_SALDO_SUBTOTAL + PAGA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('PAGA', PAGA_SERIE, PAGA_NUMERO, null) " + " FROM SCC_PAGARES " + " WHERE PAGA_CLNT_NUMERO = " + s16 + " AND PAGA_STATUS IN ('I','L','P','R') " + " AND PAGA_SALDO_SUBTOTAL + PAGA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('PAGA', PAGA_SERIE, PAGA_NUMERO, null) != 0 " + " ORDER BY 1";
                Vector vector = DbAppUnivC.execQuery(s18);
                String s22 = "";
                String s24 = "";
                String s28 = "";
                String s30 = "";
                boolean flag = false;
                double d = 0.0D;
                double d1 = 0.0D;
                httpsession.setAttribute("NumFact", Integer.toString(vector.size()));
                if(vector != null && vector.size() > 0)
                {
                    for(int k = 0; k < vector.size(); k++)
                    {
                        dbRecord dbrecord = (dbRecord)vector.elementAt(k);
                        String s42 = templates.generaTexto("tpoDocto" + k, "10", "10", dbrecord.getField(2));
                        String s45 = templates.generaTexto("docto" + k, "10", "10", dbrecord.getField(3));
                        String s48 = templates.generaTexto("monto" + k, "10", "10", utilerias.redondea(dbrecord.getField(4)));
                        d += Double.valueOf(dbrecord.getField(4)).doubleValue();
                        String s51 = templates.generaTexto("saldo" + k, "10", "10", utilerias.redondea(dbrecord.getField(5)));
                        d1 += Double.valueOf(dbrecord.getField(5)).doubleValue();
                        String s54 = templates.generaCheck("pago", "0");
                        String s57 = templates.generaTexto("totPago" + k, "20", "20", "0.00");
                        String s59 = utilerias.replaceString1(s42, ">", " readonly>");
                        String s61 = utilerias.replaceString1(s45, ">", " readonly>");
                        String s63 = utilerias.replaceString1(s48, ">", " readonly>");
                        String s65 = utilerias.replaceString1(s51, ">", " readonly>");
                        s54 = utilerias.replaceString1(s54, ">", " onclick=\"actualiza_saldo(" + k + ")\">");
                        String s67 = utilerias.replaceString1(s57, ">", " Onblur='total(" + k + ");' Onkeyup='actualTotales(" + k + ");' disabled>");
                        s8 = s8 + "<tr align=\"center\">";
                        s8 = s8 + templates.tablaCol(s59, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + templates.tablaCol(s61, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + templates.tablaCol(s63, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + templates.tablaCol(s65, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + templates.tablaCol(s54, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + templates.tablaCol(s67, datColorFont, datFont, datTamFont, datColorRen);
                        s8 = s8 + "</tr>";
                    }

                }
                s8 = s8 + "<tr align=\"center\">";
                s8 = s8 + templates.tablaCol("Totales", datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + templates.tablaCol(utilerias.redondea(Double.toString(d)), datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + templates.tablaCol(utilerias.redondea(Double.toString(d1)), datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
                s8 = s8 + "</tr>";
                String s37 = templates.generaTexto("txtSub", "20", "20", "0.00");
                String s39 = templates.generaTexto("txtAnti", "20", "20", "0.00");
                String s43 = templates.generaTexto("txtTot", "12", "20", "0.00");
                s4 = templates.generaTextArea("comentario", "1000", "60", "5", s4);
                s4 = utilerias.replaceString1(s4, ">", " onChange=\"javascript:this.value=this.value.toUpperCase();\">");
                String s46 = utilerias.replaceString1(s37, ">", " readonly>");
                String s49 = utilerias.replaceString1(s39, ">", " Onblur='totalgen()'>");
                s43 = utilerias.replaceString1(s43, ">", "  readonly>");
                String s52 = templates.generaHidden("edo_pago", "0");
                String s55 = templates.getHost();
                String s58 = dirPlantillasGenerales + plant_pago;
                String s60 = Genera_JavaScript();
                s12 = templates.generaPlantilla(s58, s55);
                s12 = utilerias.replaceString1(s12, "--script--", s60);
                s12 = utilerias.replaceString1(s12, "--clientes--", genera_clientes(s, s16));
                s12 = utilerias.replaceString1(s12, "--tabla_grid--", s8);
                s12 = utilerias.replaceString1(s12, "--txtSub--", s46);
                s12 = utilerias.replaceString1(s12, "--txtAnti--", s49);
                s12 = utilerias.replaceString1(s12, "--txtTot--", s43);
                s12 = utilerias.replaceString1(s12, "--txtCom--", s4);
                s12 = utilerias.replaceString1(s12, "--folio--", folio);
                s12 = utilerias.replaceString1(s12, "--comprobante--", "");
                s12 = utilerias.replaceString1(s12, "--hidden--", s52);
            }
            if(s14.equals("1"))
            {
                float f = Float.parseFloat("0.00");
                int i = Integer.parseInt(httpsession.getAttribute("NumFact").toString());
                String s20 = httpservletrequest.getParameter("cliente") + ",|";
                for(int j = 0; j < i; j++)
                {
                    String s25 = httpservletrequest.getParameter("totPago" + Integer.toString(j));
                    if(s25 != null && !s25.trim().equals(""))
                    {
                        f += Float.parseFloat(utilerias.replaceString(s25.trim(), ",", ""));
                        s20 = s20 + httpservletrequest.getParameter("tpoDocto" + Integer.toString(j)) + ";" + httpservletrequest.getParameter("docto" + Integer.toString(j)) + ";" + utilerias.replaceString(s25, ",", "") + "|";
                    }
                }

                String s26 = httpservletrequest.getParameter("txtAnti");
                f += Float.parseFloat(utilerias.replaceString(s26.trim(), ",", ""));
                float f1 = Float.parseFloat(utilerias.replaceString(s26, ",", ""));
                if(s26 != null && !s26.trim().equals("") && f1 > 0.0F)
                    s20 = s20 + "ANTI;;" + utilerias.replaceString(s26, ",", "") + "|";
                s20 = s20 + "," + utilerias.validaNulo(httpservletrequest.getParameter("comentario")) + ",";
                ejecuta ejecuta1 = new ejecuta();
                String s32 = ejecuta.store("SCC_P_INSERTA_PAGO_INTERNET(,N,V,V,V)", s20, 3, 1);
                String s33 = "";
                String s34 = "";
                String s35 = "";
                String s36 = "";
                String s38 = "";
                if(s32.indexOf("-") >= 0)
                {
                    s38 = s32.substring(0, s32.indexOf("-"));
                    String s40 = s32.substring(s32.indexOf("-") + 1, s32.indexOf(";"));
                    folio = "Folio Internet: " + s38 + "-" + s40;
                    s36 = s40;
                    s35 = "<input type='reset' name='btn_com' value='Comprobante'  OnClick = \"javascript:window.open('/scm/servlet/pago?serie=" + s38 + "&numero=" + s40 + "','window','resizable,scrollbars=1,width=840,height=400,left = 80,top = 100');\">";
                } else
                {
                    folio = "\"" + s32 + "\" Existio un Error al Insertar en la BD. Consulte al Administrador";
                    s35 = "";
                }
                String s41 = templates.getHost();
                String s44 = dirPlantillasGenerales + plant_pago_folio;
                s12 = templates.generaPlantilla(s44, s41);
                s12 = utilerias.replaceString1(s12, "--folio--", folio);
                s12 = utilerias.replaceString1(s12, "--comprobante--", s35);
                String s47 = s38;
                String s50 = folio.substring(folio.indexOf("-") + 1).trim();
                String s53 = Traza.rellenaIzquierda(s20.substring(0, s20.indexOf(",")), 17, "0");
                String s56 = " select  substr (clnt_razon_social, 1, 50) from scc_clientes, scc_pagos_internet ";
                s56 = s56 + " where clnt_stcl_clave = 'ACTI' and pain_clnt_numero = clnt_numero ";
                s56 = s56 + " and pain_serie = '" + s47 + "' and pain_numero = '" + s50 + "' order by clnt_numero ";
                Vector vector1 = DbAppUnivC.execQuery(s56);
                dbRecord dbrecord1 = (dbRecord)vector1.elementAt(0);
                String s62 = dbrecord1.getField(1);
                String s64 = "" + f;
                String s66 = s64;
                String s68 = s64;
                s66 = s64.substring(0, s64.indexOf("."));
                int l = s64.indexOf(".") + 1;
                s68 = s64.substring(l);
                s66 = Traza.rellenaIzquierda("" + s66, 9, "0");
                s68 = Traza.rellenaDerecha("" + s68, 2, "0");
                String s69 = "?s_transm=" + Traza.rellenaIzquierda(s36, 20, "0");
                s69 = s69 + "&c_referencia=" + s53;
                s69 = s69 + "&t_importe=" + s66 + "." + s68;
                s69 = s69 + "&val_1=" + s62;
                s69 = s69 + "&val_2=MOC";
                s12 = utilerias.replaceString1(s12, "--pagina--", "/scm/servlet/ejecutaPost" + s69);
            }
        }
        return s12;
    }

    public static String genera_clientes(String s, String s1)
    {
        String s2 = "";
        try
        {
            String s3 = "SELECT uspe_norm_rest ";
            s3 = s3 + "FROM  scc_usuarios_perfil ";
            s3 = s3 + "WHERE uspe_clave = UPPER('" + s + "')";
            String s4 = utilerias.valorSqlUni(s3);
            String s5 = "";
            if(s4.equals("N"))
            {
                s5 = "SELECT clnt_numero, clnt_numero ||' - '|| SUBSTR(clnt_razon_social,1,30) ";
                s5 = s5 + "FROM  scc_clientes ";
                s5 = s5 + "WHERE clnt_stcl_clave = 'ACTI' ";
                s5 = s5 + "ORDER BY clnt_numero";
            } else
            {
                s5 = "SELECT clnt_numero, clnt_numero ||' - '|| SUBSTR(clnt_razon_social,1,30) ";
                s5 = s5 + "FROM  scc_clientes_usuario, scc_clientes ";
                s5 = s5 + "WHERE clus_uspe_clave = UPPER('" + s + "') ";
                s5 = s5 + "AND   clnt_numero     = clus_clnt_numero ";
                s5 = s5 + "AND   clnt_stcl_clave = 'ACTI' ";
                s5 = s5 + "ORDER BY 2";
            }
            s2 = templates.generaComboJump("cliente", s5, s1);
        }
        catch(Exception exception)
        {
            System.out.println("Error al generer los clientes; pago en linea: " + exception.toString());
        }
        return s2;
    }

    static String dirPlantillasGenerales = "";
    static String datColorRen = "";
    static String datFont = "";
    static String datTamFont = "";
    static String datColorFont = "";
    static String usuario = "";
    static String plant_pago = "pgral_ideograma/pagolinea.html";
    static String plant_pago_folio = "pgral_ideograma/pago_folio.html";
    static String plant_pago_confirma = "pgral_ideograma/pago.html";
    static String folio = " ";

}